/*
 * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.xuidemo.fragment.userinfo;

import android.view.View;
import android.widget.Toast;

import com.xuexiang.xaop.annotation.SingleClick;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xrouter.annotation.AutoWired;
import com.xuexiang.xui.widget.actionbar.TitleBar;
import com.xuexiang.xui.widget.textview.supertextview.SuperTextView;
import com.xuexiang.xuidemo.R;
import com.xuexiang.xuidemo.base.BaseFragment;
import com.xuexiang.xuidemo.fragment.SettingFragment;

import butterknife.BindView;

@Page(name = "UserInfo", anim = CoreAnim.none)
public class UserInfoFragment extends BaseFragment {
    @BindView(R.id.btn_account)
    SuperTextView account;
    @BindView(R.id.btn_setting)
    SuperTextView setting;
    @BindView(R.id.btn_update)
    SuperTextView update;
    @BindView(R.id.btn_help)
    SuperTextView help;
    @BindView(R.id.btn_feedback)
    SuperTextView feedback;
    @BindView(R.id.btn_about)
    SuperTextView about;
    @BindView(R.id.agreement)
    SuperTextView agreement;
    @BindView(R.id.privacy)
    SuperTextView privacy;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_user_info;
    }

    @Override
    protected void initViews() {
        account.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClick(SuperTextView superTextView) {
                Toast.makeText(getContext(), "account", Toast.LENGTH_SHORT).show();
                openNewPage(AccountFragment.class);
            }
        });
        setting.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClick(SuperTextView superTextView) {
                Toast.makeText(getContext(), "setting", Toast.LENGTH_SHORT).show();
                openNewPage(SettingFragment.class);
            }
        });
        update.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClick(SuperTextView superTextView) {
                Toast.makeText(getContext(), "当前已是最新版本", Toast.LENGTH_SHORT).show();
            }
        });
        help.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClick(SuperTextView superTextView) {
                Toast.makeText(getContext(), "help", Toast.LENGTH_SHORT).show();
            }
        });
        feedback.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClick(SuperTextView superTextView) {
                Toast.makeText(getContext(), "feedback", Toast.LENGTH_SHORT).show();
            }
        });
        about.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClick(SuperTextView superTextView) {
                Toast.makeText(getContext(), "about", Toast.LENGTH_SHORT).show();
            }
        });
        agreement.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClick(SuperTextView superTextView) {
                Toast.makeText(getContext(), "user agreement", Toast.LENGTH_SHORT).show();
            }
        });
        privacy.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
            @Override
            public void onClick(SuperTextView superTextView) {
                Toast.makeText(getContext(), "privacy", Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override
    protected TitleBar initTitle() {
        TitleBar titleBar = super.initTitle();
        titleBar.setLeftImageResource(R.drawable.smallsmallpoint);
        titleBar.setLeftClickListener(new View.OnClickListener() {
            @Override
            @SingleClick
            public void onClick(View v) {
            }
        });
        return titleBar;
    }
}
